ImageView同寬不同長


Posted by Limon on 2023-06-02

有一個新需求是recyclerView item要每個ImageView寬match_parent,長則依照每個照片不失真為前提,每個照片的長度不一樣。

recyclerView可以設定setHasFixedSize,設定為false recyclerView會依照每個item height wrap_content。

ImageView xml加上

android:adjustViewBounds="true"
android:scaleType="fitStart"

本來我一直在載入圖片的code調整,結果發現在ImageView加上自動調整的屬性就好了

Picasso.get().load(url).placeholder(defaultDrawable).into(imageView);









Related Posts

[cmd] 怎麼使用 command line 來 kill 正在某個 port 上面的 process?

[cmd] 怎麼使用 command line 來 kill 正在某個 port 上面的 process?

ASP.NET Core Web API 入門教學 - 同時取得父子資料

ASP.NET Core Web API 入門教學 - 同時取得父子資料

API 留言板練習-Part 3 : 增加[載入更多]功能

API 留言板練習-Part 3 : 增加[載入更多]功能


Comments